package com.hyt.it.ogt.ks.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.ks.api.kw.model.CancelSubmitPaperDTO;
import com.hyt.it.ogt.ks.feign.model.ExamCandidate;
import com.hyt.it.ogt.ks.feign.model.param.FaceAuthFailParam;
import com.hyt.it.ogt.ks.feign.model.vo.FaceAuthFailVO;
import com.hyt.it.ogt.ks.model.entity.CandidatePaper;
import com.hyt.it.ogt.ks.model.entity.CandidateProcess;
import com.hyt.it.ogt.ks.model.entity.CandidateTimeLength;
import com.hyt.it.ogt.ks.model.vo.*;
import com.hyt.it.ogt.ks.mq.model.CandidateInfoUpdateDTO;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 考生考试过程表 服务类
 *
 * @author chengxh
 * @since 2020-06-17
 */
public interface ICandidateProcessService extends IService<CandidateProcess> {

	/***
	 * 根据考试id和考生id获取考试过程表数据
	 * @param examId
	 * @param candidateId
	 * @return
	 */
	CandidateProcess getCandidateProcessByExamIdAndCandidateId(String examId, String candidateId);
    /**
     * 获取试卷结构，在进入开考页面中调用.
     *
     * @param examId
     * @param candidateId
     * @return
     */
    ExamPaperTopicVO getTopic(String examId, String candidateId, HttpServletRequest request);

    /**
     * 修改剩余时长，强制结束考试
     * @param examId 考试ID
     * @param candidateId 考生ID
     * @return
     * @throws Exception
     */
    CandidateStatusVO getTimeLength(String examId, String candidateId, Integer sort);

    /**
     * 获取小题信息
     *
     * @param itemId
     * @param candidateId 考生ID
     * @param examId 考试ID
     * @return PaperBigQuestionVO
     */
    PaperBigQuestionVO getQuestion(String itemId, String candidateId, String examId, Integer paperSort, String language,
                                   Integer childItemSort, HttpServletRequest request);

    /**
     * 考生登录
     * @param requestVO
     * @return
     */
    ApiResponse<CandidateInfoVO> doLogin(CandidateLoginRequestVO requestVO, HttpServletRequest request);

    /**
     * 通过MQ修改考务考生信息
     * @param obj
     */
    void updateKwCandidateInfo(CandidateInfoUpdateDTO obj);


    /**
     * 计算剩余时长
     * @param candidateTimeLength
     * @param currentTimeMillis
     * @return Long
     */
    Long calcRemainTime(CandidateTimeLength candidateTimeLength, Long currentTimeMillis, Integer paperSort);

    /**
     * 修改考生是否在线状态
     * @param examId
     * @param examCandidateId
     * @param onlineExamState
     */
    void updateCandidateOnlineExamState(@RequestParam String examId, @RequestParam String examCandidateId,
                                        @RequestParam Boolean onlineExamState,
                                        @RequestParam(required = false) Integer state);

    /**
     * 撤销交卷
     * @param cancelSubmitPaperDTO
     */
    void cancelSubmitPaper(CancelSubmitPaperDTO cancelSubmitPaperDTO);

    /**
     * 重置考试
     * @param examId
     * @param candidateId
     */
    void redoExam(String examId, String candidateId);

    /**
     * 初始化考生考试数据
     * @param vo
     */
    void initCandidateData(InitCandidateDataVO vo);

    Long calcRemainTimeByNormal(long remainTime, long accessTime, Long currentTimeMillis, long extraTime);

    /**
     * 获取考试准考证信息
     * @param examId
     * @param admissionNumber
     * @param loginType
     * @return
     */
    AdmissionVO getAdmissionInfo(String examId, String admissionNumber, String loginType, String from);

    /**
     *
     * @param candidateId
     * @param examId
     * @param current
     * @param paperSort
     * @return
     */
    PaperTopicItemListVO getQuestionListByTopicId(String candidateId, String examId, Integer current, Integer paperSort);

    /**
     * 获取大屏考生信息
     * @param examId
     * @return
     */
    List<CandidateTimeLength> getMonitorScreen(String examId);

    void forceFinishExam(String json);
    
    /**
     * 获取已切屏次数
     * @param examId
     * @param candidateId
     * @return
     */
    AlreadyOverScreenCountVO getAlreadyOverScreenCount(String examId, String candidateId);

    /**
     * 批量考生加时
     * @param json
     * @return 操作不成功的考生
     */
    void addExtraTimeByBatch(String json);

    /**
     * 重置登录次数
     * @param examId
     * @param candidateId
     */
    void resetLoginCount(String examId, String candidateId, String userId);

    /**
     * 计算剩余时长
     * @param examId
     * @param extraTime
     * @param remainingTime
     * @param accessTime
     * @param currentTimeMillis
     * @return
     */
    Long calcRemainTime(String examId, String candidateId, Long extraTime, Long remainingTime, Long accessTime, Long currentTimeMillis, Integer paperSort);

    /**
     * 获取剩余时长
     * @param candidatePaper
     * @return
     */
    Long getRemainTime(CandidatePaper candidatePaper);

    /**
     * 考生改为考中状态（目前只有兴业银行编程题需要使用）
     * @param examId
     * @param candidateId
     */
    void change2Testing(String examId, String candidateId);

    List<CancelCommitPaper> getCandidateAllPaperList(String examId, String candidateId);

    void clearInitPaperDataByCandidateId(Integer examCode, String zkz);

    void clearInitPaperDataByCandidateId(String candidateId);

    void revokeToken(String accessToken);

    void overScreenLog(OverScreenLogVO overScreenLogVO);

    void setPassCandidatePhotoVerification(String examId, String candidateId);

    String getExamCandidateByAdmissionNumber(String examId, String candidateId);

    /**
     * 人脸核身验证失败，返回人脸核身验证失败是否申请跳过
     *
     * @param faceAuthFailParam 参数
     * @return 返回人脸核身验证失败是否申请跳过
     */
    FaceAuthFailVO faceVerifyFail(FaceAuthFailParam faceAuthFailParam);

    void dataCheck(String examId);
}
